function setActiveRecord(storage, recordRID){
	var gridRecord = document.getElementById(storage+'_'+recordRID);
	var prevRecord = document.getElementById(storage+'_activerecord');
	if(prevRecord.value!=''){
		if(document.getElementById(storage+'_'+prevRecord.value)) 
		document.getElementById(storage+'_'+prevRecord.value).className = '';
	}
	prevRecord.value = recordRID;
	gridRecord.className = 'rowSel';	
}

function getActiveRecord(storage){
	return document.getElementById(storage+'_activerecord').value;
}

function RecalcForm(){
	var summ_tour = parseFloat(document.getElementById('summ_tour').value);
	var curr_cource = parseFloat(document.getElementById('curr_cource').value);
	var discount_per = parseFloat(document.getElementById('discount_per').value);
	var discount_fix = parseFloat(document.getElementById('discount_fix').value);
	var bank_s = parseFloat(document.getElementById('bank_s').value);
	var touroperator_commision = parseFloat(document.getElementById('touroperator_commision').value);
	var touroperator_koeff = parseFloat(document.getElementById('touroperator_koeff').value);
	var doxodOBJ = document.getElementById('doxod');
	if(summ_tour=='' || curr_cource=='') return;
	document.getElementById('summ').value = Math.round((summ_tour-summ_tour*(discount_per/100)-discount_fix)*curr_cource*touroperator_koeff*(1+bank_s));
	RecalcDoxod();
	return;				
}
function RecalcDoxod(){
	var summ_tour = parseFloat(document.getElementById('summ_tour').value);
	var order_summ = parseFloat(document.getElementById('order_summ').value);
	var summ_pay = parseFloat(document.getElementById('summ_pay').value);
	var curr_cource = parseFloat(document.getElementById('curr_cource').value);
	var discount_per = parseFloat(document.getElementById('discount_per').value);
	var discount_fix = parseFloat(document.getElementById('discount_fix').value);
	var bank_s = parseFloat(document.getElementById('bank_s').value);
	var touroperator_commision = parseFloat(document.getElementById('touroperator_commision').value);
	var touroperator_koeff = parseFloat(document.getElementById('touroperator_koeff').value);
	var doxodOBJ = document.getElementById('doxod');
	var fdoxodOBJ = document.getElementById('fdoxod');
	var summ = parseFloat(document.getElementById('summ').value);
	var rest = document.getElementById('rest');
	if(summ_tour=='' || curr_cource=='') return;
	doxodOBJ.value = Math.round((summ_tour*(touroperator_commision/100)-discount_fix-summ_tour*(discount_per/100))*curr_cource);
	if(order_summ > 0) fdoxodOBJ.value = Math.round(summ - (summ*bank_s)- order_summ);
	else fdoxodOBJ.value = '';
	if(summ_pay > 0) rest.value = summ - summ_pay;
	else rest.value = '';
	return;
}
